package com.wangsd.core.util;

import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

public class ArrayUtils {

	/**
	 * 
	 * Description: 数组去重
	 * @return
	 */
	public static Integer[] duplicateRemoval(Integer[] nums){
		Set<Integer> set = new TreeSet<Integer>();
		for (int i : nums) {
			set.add(i);
		}
		Integer[] arr2 = set.toArray(new Integer[0]);		
		return arr2;		
	}
	
	public static void main(String[] args) {
		/*int[] testArr = {-1,1,2,2,3};
		Set<Integer> set = new TreeSet<Integer>();
		for (int i : testArr) {
			set.add(i);
		}
		Integer[] arr2 = set.toArray(new Integer[0]);
		int[] result = new int[arr2.length];
		for (int i = 0; i < result.length; i++) {
			result[i] = arr2[i];
		}*/
		Integer[] testArr = {-1,1,2,2,3};
		System.out.println(Arrays.toString(duplicateRemoval(testArr)));
	}
}
